<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: admin
  Date: 2019/12/4
  Time: 15:25
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="com.example.association2.model.User" %>
<%@ page import="com.example.association2.model.Association" %>
<%@ page import="java.util.List" %>
<%@ page import="static java.lang.Integer.parseInt" %>

<html lang="zh-CN">
<head>
    <%@include file="head.jsp" %>
</head>
<body class="nav-md">
<div class="container body">
    <div class="main_container">
        <!-- 引入bar -->
        <jsp:include page="sidebar.jsp"/>
        <jsp:include page="topbar.jsp"/>
        <!-- page content -->
        <div class="right_col" role="main">
            <div class="page-title">
                <div class="title_left">
                    <h3>个人信息</h3>
                </div>
            </div>
            <div class="row">
                <div class="col-md-12">
                    <div class=" x_panel">
                        <div class="x_content">
                            <form action="/editPassword" id="form">
                                <input  name="userId"value="${userId}" hidden="hidden"/>
                                <div class="item form-group">
                                <br>
                                    <label class="control-label col-md-3 col-sm-3 col-xs-12" >请输入新密码 <span
                                            class="required">*</span>
                                    </label>
                                    <div class="col-md-6 col-sm-6 col-xs-12">
                                        <input  name="password" id="pass" class="form-control col-md-7 col-xs-12" placeholder=""required="" type="password">
                                    </div>
                                </div>
                                <br>
                                <br>
                                <div class="item form-group">
                                <br>
                                    <label class="control-label col-md-3 col-sm-3 col-xs-12" >请确认新密码 <span
                                            class="required">*</span>
                                    </label>
                                    <div class="col-md-6 col-sm-6 col-xs-12">
                                        <input  name="password1" id="pass1" class="form-control col-md-7 col-xs-12" placeholder=""required="" type="password">
                                    </div>
                                </div>
                                
                                <div class="ln_solid"></div>
                                <div class="form-group">
                                    <div class="col-md-6 col-md-offset-3"style="margin-bottom: 10px;margin-top: 10px">
                                       <button type="button" onclick="check1()" class="btn btn-default submit" >修改密码</button>
                                    </div>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script type="text/javascript">

function check1(){
	var form = document.getElementById('form');
	var pwd = document.getElementById('pass').value;
	var pwd1 = document.getElementById('pass1').value;
	if(pwd == "")
	{
		alert('密码不能为空');
	}
	else if(pwd1 == "")
	{
		alert('确认密码不能为空');
	}
	else if(pwd != pwd1)
	{
		alert('两次密码不一致，请重新输入!');
		
	}
	else if (pwd.length >20 )
	{
		alert('密码不能大于20位!');
	}
	else if(checkPass(pwd)<3)
	{
        alert('密码复杂度不够，请重新设置！需至少6位，且包含大小写字母和数字。');
	}
	else{form.submit();}
}
function checkPass(pwd){
    var str = 0;
	if (pwd.length <6 )
	{
		return 0;
	}
    if(pwd.match(/([a-z])+/)){
        str++;
    }
    if(pwd.match(/([0-9])+/)){
        str++;
    }
    if(pwd.match(/([A-Z])+/)){
        str++;
    }
    if(pwd.match(/[^a-zA-Z0-9]+/)){
        str++;
    }
    return str;
}
</script>

<script  type="text/javascript" src="../static/js/main4.js"></script>
</body>

<!-- /page content -->
<jsp:include page="footer.jsp"/>
</html>


